package two;

import javax.management.Notification;
import javax.management.NotificationListener;

import one.Hello;

/**
 *创建一个监听，监听到的Notification消息包将由此类负责处理
 */
public class HelloListener implements NotificationListener {

	@Override
	public void handleNotification(Notification n, Object handback) {
		System.out.println("type="+n.getType());
		System.out.println("source="+n.getSource());
		System.out.println("seq="+n.getSequenceNumber());
		System.out.println("sendTime="+n.getTimeStamp());
		System.out.println("message="+n.getMessage());//Jack
		if(handback != null){
			if(handback instanceof Hello){
				Hello hello = (Hello)handback;
				hello.sayHello(n.getMessage());
			}
		}
	}

}
